package com.yipinhouse.backstage.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.yipinhouse.backstage.client.BackstageManageClient;
import com.yipinhouse.backstage.client.param.ShopParam;
import com.yipinhouse.backstage.service.ShopService;
import com.yipinhouse.backstage.service.dto.ShopDto;
import com.yipinhouse.backstage.service.param.ShopServiceParam;
import com.yipinhouse.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
@RequestMapping("backstage")
public class BackstageManageApiImpl implements BackstageManageClient {

    @Resource
    private ShopService shopService;


    /**
     * 添加门店
     *
     * @param param
     * @return
     */
    @Override
    public Result addShop(ShopParam param) {
        log.info("添加门店：{}", param);
        ShopServiceParam shopServiceParam = BeanUtil.copyProperties(param, ShopServiceParam.class);
        ShopDto shopDto = shopService.addShop(shopServiceParam);
        return Result.getInstance(ShopDto.class).setData(shopDto);
    }

}
